<template>
	<footer class="footer">
		<span class="todo-count">剩余<strong>数量值{{ leftCount }}</strong></span>
		<ul class="filters">
			<li>
				<a href="javascript:;" :class="{selected: selectType === 'all'}" @click="change('all')">全部</a>
			</li>
			<li>
				<a href="javascript:;" :class="{selected: selectType === 'active'}" @click="change('active')">未完成</a>
			</li>
			<li>
				<a href="javascript:;" :class="{selected: selectType === 'ready'}" @click="change('ready')">已完成</a>
			</li>
		</ul>
		<button class="clear-completed" v-if="complete" @click="eliminate">清除已完成</button>
	</footer>
</template>

<script>
	export default {
		data() {
			return {
				selectType: 'all'
			}
		},
		props: {
			list: {
				type: Array,
				required: true
			}
		},
		computed: {
			leftCount() {
				return this.list.filter(item => !item.isDone).length
			},
			complete() {
				return this.list.some(item => item.isDone)
			}
		},
		methods: {
			change(type) {
				this.selectType = type
				this.$emit('change',type)
			},
			eliminate() {
				this.$emit('eliminate')
			}
		}
	}
</script>
